//引入myAxios实例
import myAxios from '@/request.ts'

/**
 * 用户注册
 * @param params
 */
export const userRegister = async (params: any) => {
  return await myAxios.request({
    url: '/api/user/register', //要请求的接口路径
    method: 'POST',
    data: params,
  })
}

/**
 * 用户登录
 * @param params
 */
export const userLogin = async (params: any) => {
  return await myAxios.request({
    url: '/api/user/login', //要请求的接口路径
    method: 'POST',
    data: params,
  })
}

/**
 * 获取当前用户信息接口
 * @param params
 */
export const getCurrentUser = async () => {
  return await myAxios.request({
    url: '/api/user/current', //要请求的接口路径
    method: 'GET',
  })
}

/**
 * 获取用户列表
 * @param username
 */
export const searchUsers = async (username: any) => {
  return await myAxios.request({
    url: '/api/user/search',
    method: 'GET',
    params: {
      username,
    },
  })
}

/**
 * 删除用户
 * @param id
 */
export const deleteUser = async (id: string) => {
  return myAxios.request({
    url: '/api/user/delete',
    method: 'POST',
    data: {
      id
    },
  })
}
